﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMSADL.Warehouse;
using WMSAML.Warehouse;
using System.Data;

namespace WMSABL.Warehouse
{
    public class PD_PostionBLL
    {
        #region  BasicMethod
        private readonly PD_PostionDAL dal = new PD_PostionDAL();
        public bool Exists(int NID)
        {
            return dal.Exists(NID);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(PD_PostionEntity entity)
        {
            return dal.Add(entity);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(PD_PostionEntity entity)
        {
            return dal.Update(entity);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PD_PostionEntity GetEntity(int NID)
        {
            return dal.GetEntity(NID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
       
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<PD_PostionEntity> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<PD_PostionEntity> DataTableToList(DataTable dt)
        {
            List<PD_PostionEntity> modelList = new List<PD_PostionEntity>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                PD_PostionEntity model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToentity(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  BasicMethod
    }
}
